// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()
const db = cloud.database()
const _ = db.command

// 云函数入口函数
exports.main = async (event, context) => {
  // const wxContext = cloud.getWXContext()
  const organizeCollect = db.collection('kq_organize')
  const thisID = organizeCollect.where({'_id':event._id,'member._openid':event._openid})

  return thisID.get().then(res => {
    console.log(res)
    return thisID.update({
      data:{
        'member.$.status':_.set('1')
      }
    })
  })
  // return {
  //   event,
  //   openid: wxContext.OPENID,
  //   appid: wxContext.APPID,
  //   unionid: wxContext.UNIONID,
  // }
}